764A - Taymyr is calling you - CodeForces Solution


brute force implementation math *800

Please click on ads to support us..

Python Code:

n = [int(x) for x in input().split()]
x = n[0]
y = n[1]
s = n[2]
count = []
for i in range(1, s + 1):
    if i % x == 0 and i % y == 0:
        count.append(i)
print(len(count))

C++ Code:

#include <bits/stdc++.h>
using namespace std;

#define dbg(n, m) cout << n << " " << m << '\n'; return;
#define nl cout << endl
#define all(a) a.begin(), a.end()
#define FOR(i, n, p) for (int i = 0; i < n; i++) { cout << p << " "; }

struct Pair {
	int min;
	int max;
};

template<typename T>
class Myclass {
private:
	T value;
public:
	Myclass (T x) {
		value = x;
	}
	T getValue () {
		return value;
	}
};

int gcd (int a, int b) {
	return (b == 0) ? a : gcd(b, a % b);
}

void test () {
	int n, m, z;
	cin >> n >> m >> z;
	int U = m * n / gcd(n, m);
	cout << z / U << endl;
}

int main () {
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);
	int t = 1;
	// cin >> t;
	while (t--) test();
	return 0;
}


Comments

Submit
0 Comments
More Questions

8A - Train and Peter
591A - Wizards' Duel
1703G - Good Key Bad Key
1705A - Mark the Photographer
1707A - Doremy's IQ
1706B - Making Towers
1325B - CopyCopyCopyCopyCopy
1649C - Weird Sum
1324B - Yet Another Palindrome Problem
525A - Vitaliy and Pie
879A - Borya's Diagnosis
1672B - I love AAAB
1673A - Subtle Substring Subtraction
1345A - Puzzle Pieces
711A - Bus to Udayland
779B - Weird Rounding
1703D - Double Strings
1704C - Virus
63A - Sinking Ship
1704B - Luke is a Foodie
298B - Sail
239A - Two Bags of Potatoes
1704E - Count Seconds
682A - Alyona and Numbers
44A - Indian Summer
1133C - Balanced Team
1704A - Two 0-1 Sequences
1467A - Wizard of Orz
1714E - Add Modulo 10
1714A - Everyone Loves to Sleep